<?php

	include("common.php");
	
	if(!empty($_POST)){
		
		$result = mysql_query("SELECT * FROM `197_settings` WHERE `name` = '" . $_POST['name'] . "'");
		$num = mysql_num_rows($result);
		$status = (bool)($num == 0);
		if($status){
			mysql_query("INSERT INTO `197_settings` ( `name`, `value` ) VALUES ( '" . $_POST['name'] . "',  '" . $_POST['value'] . "')");
		}
		
		include("header.php");
		
?>
<h1>新增設定值</h1>
<p><?php if($status){ echo '修改成功'; } else { echo '已有相同名稱的設定'; } ?>，請<a href="settings.php">按此</a>返回。</p>
<?php

		include("sidebar.php");
		include("footer.php");
		exit;
	}
	
?>